package bavaria.hightech.testit.pruefungen.ss11;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import bavaria.hightech.testit.pruefungen.ss11.Money.Currency;
import bavaria.hightech.testit.pruefungen.ss11.Money.WrongCurrencyException;


public class MoneyTest {
	
	private Money m1;
	private Money m2;
	private Money m3;
	private Money m4;

	@Before
	public void setUp() throws Exception {
		m1 = new Money(10000, Currency.EURO);
		m2 = new Money(5000, Currency.EURO);
		m3 = new Money(10000, Currency.DOLLAR);
		m4 = new Money(-5000,Currency.EURO);
	}

	@Test
	public void testAdd() {
		Money exp = new Money(15000,Currency.EURO);
		boolean exceptionThrown = false;
		try{
		assertEquals(exp, m1.add(m2));
		assertEquals(m2, m1.add(m4));
		}catch(WrongCurrencyException e){
			e.printStackTrace();
		}
		try{
		m1.add(m3);
		}catch(WrongCurrencyException e){
			exceptionThrown = true;
            e.printStackTrace();		
		}
		
		assertTrue(exceptionThrown);
	}

}
